//
//  MaskView.swift
//  FearfulNotification
//
//  Created by 筱鹏 on 2018/1/13.
//  Copyright © 2018年 筱鹏. All rights reserved.
//

import UIKit

class MaskView: UIView {

    let label: UILabel!
    
    override init(frame: CGRect) {
        label = UILabel()
        super.init(frame: frame)
        self.backgroundColor = Theme.color.background
        self.alpha = 0.0
        self.addSubview(label)
        configSubview()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("maskView not coder init")
    }
    
    func configSubview() {
        label.frame = CGRect(x: 0, y: (self.frame.height - self.frame.width) * 0.5, width: self.frame.width, height: self.frame.width)
        
    }
    
    func showView(on view:UIView) {
        view.addSubview(self)
        UIView.animate(withDuration: 0.2) {
            self.alpha = 1.0
        }
    }
    
    func hideView() {
        UIView.animate(withDuration: 0.2, animations: {
            self.alpha = 0.0
        }) { (finish) in
            self.removeFromSuperview()
        }
    }
}
